package com.rakuten.api.mule.transformers;

import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.api.transport.PropertyScope;
import org.mule.transformer.AbstractMessageTransformer;


import com.rakuten.api.mule.model.FindShopInfo;



public class ObjectToString extends AbstractMessageTransformer {
	@Override
	public Object transformMessage(MuleMessage message, String outputEncoding)
			throws TransformerException {

		try {
			//System.out.println("Payload"+message.getPayloadAsString());
			FindShopInfo shopInfo = message.getPayload(FindShopInfo.class);
			String shopId = shopInfo.getShop().getShopId();
			message.setProperty("shopId",
					shopId, PropertyScope.SESSION);
			String merchantId = shopInfo.getMerchant().getMerchantId();
			message.setProperty("merchantId",
					merchantId, PropertyScope.SESSION);			
			return shopId;
		} catch (Exception ex) {
			throw new TransformerException(this, ex);
		}
	}
}
